<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h1>人物介绍-贾玲</h1>
      <p>
        <router-link to="/">Go to Home</router-link>
        <router-link to="/about">Go to About</router-link>
      </p>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.js"></script>
    <script src="https://unpkg.com/vue-router@4"></script>
    <script>
      const NotFound = { template: '<p>Page not found</p>' }
      const Home = { template: '<p>home page</p>' }
      const About = { template: '<p>about page</p>' }

      const routes = {
        '/': Home,
        '/about': About,
      }

      new Vue({
        el: '#app',
        data: {
          currentRoute: window.location.pathname,
        },
        computed: {
          ViewComponent() {
            return routes[this.currentRoute] || NotFound
          },
        },
        render(h) {
          return h(this.ViewComponent)
        },
      })
    </script>
  </body>
</html>
